﻿package bacIns.exchangeddata 
{
	/**
	 * ...
	 * @author Doan Nguyen Thuy Nha Truc (Bamboo)
	 */
	import flash.events.EventDispatcher;
	import game.constants.ConstData
	import game.events.EventData;
	import flash.events.Event;
	public class PlayerBankerInfo extends EventDispatcher
	{
		
		public var historyType_1:String;
		public var historyType_2:String;
		public function PlayerBankerInfo() 
		{
			
		}
		
		public function returnSetHistoryType_1(result:String):String{
			
			var numberHistory:int =  int(result.substr(ConstData.POS_HIS_RESULT, ConstData.LEN_NUM_HIS));
			var routeOffset:int = ConstData.POS_HIS_RESULT + ConstData.LEN_NUM_HIS + (ConstData.LEN_VALUE_HIS * numberHistory);
			var lenRoute:int = int(result.substr(routeOffset, ConstData.LEN_NUM_HIS));
			
			lenRoute = lenRoute * ConstData.LEN_CODE + ConstData.LEN_HIS_ROUTE;
			var resultStr:String = result.substr(routeOffset, lenRoute);
			//trace("resultStr1"+resultStr);
			return resultStr;
		}
		
		public function returnSetHistoryType_2(result:String):String{
			
			var numberHistory:int =  int(result.substr(ConstData.POS_HIS_RESULT, ConstData.LEN_NUM_HIS));
			var routeOffset:int = ConstData.POS_HIS_RESULT + ConstData.LEN_NUM_HIS + (ConstData.LEN_VALUE_HIS * numberHistory);
			var lenRoute:int = int(result.substr(routeOffset, ConstData.LEN_NUM_HIS));
			
			lenRoute = lenRoute * ConstData.LEN_CODE + ConstData.LEN_HIS_ROUTE;
			routeOffset += lenRoute;
			var resultStr:String = result.substr(routeOffset, result.length - routeOffset);
			//trace("resultStr2"+resultStr);
			return resultStr;
		}
		
		public function setHistoryType_1(result:String):void {
			historyType_1 = result;
			dispatchEvent(new Event(EventData.INIT_ASK_PLAYER_BANKER_TYPE_1));
		}
		
		public function setHistoryType_2(result:String):void {
			historyType_2 = result;
			dispatchEvent(new Event(EventData.INIT_ASK_PLAYER_BANKER_TYPE_2));
		}
		
		public function returnAskRouteType_1(result:String):String {
			
				var tmpNumBetResult:int = int(result.substr(ConstData.LEN_SUCCESS_RESULT, ConstData.LEN_NUM_HIS));
				var routeOffset:int = ConstData.LEN_SUCCESS_RESULT + ConstData.LEN_NUM_HIS + (ConstData.LEN_VALUE_HIS * tmpNumBetResult);
				var lenRoute:int = int(result.substr(routeOffset, ConstData.LEN_NUM_HIS));
				lenRoute = lenRoute * ConstData.LEN_NUM_HIS + ConstData.LEN_HIS_ROUTE;
				var resultStr:String = result.substr(routeOffset, lenRoute);
				//trace("resultStr : " + resultStr);
				return resultStr;
				
		}
		
		public function setAskRouteType_1(result:String):void {
			historyType_1 = result;
			dispatchEvent(new Event(EventData.UPDATE_ASK_ROUTE_1));
		}
		
		
		public function returnAskRouteType_2(result:String):String {
			
				var tmpNumBetResult:int = int(result.substr(ConstData.LEN_SUCCESS_RESULT, ConstData.LEN_NUM_HIS));
				var routeOffset:int = ConstData.LEN_SUCCESS_RESULT + ConstData.LEN_NUM_HIS + (ConstData.LEN_VALUE_HIS * tmpNumBetResult);
				var lenRoute:int = int(result.substr(routeOffset, ConstData.LEN_NUM_HIS));
				lenRoute = lenRoute * ConstData.LEN_NUM_HIS + ConstData.LEN_HIS_ROUTE;
				
				routeOffset += lenRoute;
				var resultStr:String = result.substr(routeOffset, result.length - routeOffset);
				return resultStr;
				
		}
		
		public function setAskRouteType_2(result:String):void {
			historyType_2 = result;
			dispatchEvent(new Event(EventData.UPDATE_ASK_ROUTE_2));
		}
		
	}

}